import { applyMiddleware, createStore } from 'redux';
import { Middlewares } from './lib';
import { persistStore, autoRehydrate } from 'redux-persist';
import { AsyncStorage } from 'react-native';
import reducers from './reducers';

const createAppStore = applyMiddleware(...Middlewares)(createStore);
export default function configureStore(onComplete) {
  const store = autoRehydrate()(createAppStore)(reducers);
  const opt = {
    storage: AsyncStorage,
    transform: [],
  };
  persistStore(store, opt, onComplete);
  return store;
}
